﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GalaSoft.MvvmLight;
using MusicExplorer.Internals;

namespace MusicExplorer.ViewModel
{
    public sealed class LogViewModel : ViewModelBase
    {
        private MainWindowViewModel m_parent;
        public MainWindowViewModel Parent { get { return m_parent; } }

        public LogViewModel(MainWindowViewModel parent)
        {
            m_parent = parent;

            ResetLog();
        }

        #region PROPERTIES

        private string m_currentLog;
        public string CurrentLog
        {
            get { return m_currentLog; }
            set
            {
                if (m_currentLog != value)
                {
                    m_currentLog = value;
                    RaisePropertyChanged("CurrentLog");
                }
            }
        }

        private LogTypeEnum m_logType;
        public LogTypeEnum LogType
        {
            get { return m_logType; }
            set
            {
                if (m_logType != value)
                {
                    m_logType = value;
                    RaisePropertyChanged("LogType");
                }
            }
        }

        #endregion

        #region FUNCTIONS

        public void ResetLog()
        {
            CurrentLog = "No loading in progress.";
            LogType = LogTypeEnum.Check;
        }

        public void LogError(Exception ex)
        {
            SetLog(ex.Message, LogTypeEnum.Error);
        }

        public void SetLog(string msg, LogTypeEnum type)
        {
            CurrentLog = msg;
            LogType = type;
        }

        #endregion
    }
}
